package org.child_motivation.presentation.control;

import org.child_motivation.business.model.PersonalTask;
import org.child_motivation.business.model.TaskValue;
import org.child_motivation.business.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

@Controller
public class TaskController {

    @Autowired
    TaskService taskService;

    @RequestMapping(value="/createtask", method = RequestMethod.GET)
    public String getTask(@ModelAttribute("task")PersonalTask task, ModelMap model, HttpServletRequest request){
        model.put("taskValues", TaskValue.values());
        return "task/createtask";
    }

    @RequestMapping(value="/createtask", method = RequestMethod.POST)
    public String  createTask(@ModelAttribute("task")PersonalTask task,ModelMap model, HttpServletRequest request){

        return "redirect:frontpage";
    }
}
